//
//  TwoViewController.m
//  项目二
//
//  Created by rimi on 16/5/13.
//  Copyright © 2016年 objective. All rights reserved.
//

#import "TwoViewController.h"

@interface TwoViewController ()
/**展示数据*/
@property(nonatomic,strong)UILabel *showLabel;

/**UIDatePicker*/
@property(nonatomic,strong)UIDatePicker *datePicker;
@end

@implementation TwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"UIDatePicker";
    self.view.backgroundColor = [UIColor whiteColor];
    [self initInterface];
    [self initDataSource];
    
}

-(void)initDataSource{
    NSDate *currentDate = [NSDate date];//获取当前时间，日期
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"YYYY/MM/dd hh:mm:ss SS"];
    NSString *dateString = [dateFormatter stringFromDate:currentDate];
    NSLog(@"dateString:%@",dateString);
    
    _showLabel.text = dateString;
}

-(void)initInterface{
    [self.view addSubview:self.showLabel];
    [self.view addSubview:self.datePicker];
}
#pragma mark GET
-(UIDatePicker *)datePicker{
    if (!_datePicker) {
        _datePicker = [[UIDatePicker alloc]initWithFrame:CRM(0, 100, self.view.frame.size.width, 300)];
        _datePicker.backgroundColor = [UIColor blueColor];
    }
    return _datePicker;
}

-(UILabel *)showLabel{
    if (!_showLabel) {
        _showLabel = [[UILabel alloc]initWithFrame:CRM(0, CGRectGetMaxY(self.datePicker.frame) + 100, CGRectGetWidth(self.datePicker.frame), 100)];
        _showLabel.backgroundColor = [UIColor groupTableViewBackgroundColor];
        _showLabel.textAlignment = NSTextAlignmentCenter;
        _showLabel.text = @"获取当前时间";
    }
    return _showLabel;
}
@end
